import Vue from 'vue'
import Vuex from 'vuex'
import axios from "axios"

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list:[],
    item:{}
  },
  mutations: {
    SET_LIST(state,data){
      state.list = data
    },
    SET_ITEM(state,data){
      state.item = data
      // console.log(state.item);
    }
  },
  actions: {
    async GET_LIST({commit}){
      const oldlist = await axios.get("/api/list")
      commit('SET_LIST',oldlist.data.data)
      
    },
    GET_ITEM(context,data){
      context.commit('SET_ITEM',data)
      
    }
  },
  modules: {
  }
})
